package supe;

import javax.swing.*;
import java.awt.*;

public class GameFrame extends JFrame {
    final int step = 30;
    final int frameSize = 600;

    public void launch(){
        this.setTitle("小猫你可以吃汉堡了");
        this.setSize(frameSize,frameSize);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        while (true){
            repaint();
            try {
                Thread.sleep(200);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }
    }
    public SnakeHead snakeHead = new SnakeHead(30,570,GameUtils.rightImg);

    @Override
    public void paint(Graphics graphics){
        //背景颜色
        graphics.setColor(Color.PINK);
        graphics.fillRect(0,0,frameSize,frameSize);
        //线条颜色
        graphics.setColor(Color.BLACK);
        //画一条横线
        graphics.drawLine(0,300,600,300);
        //画一条竖线
        graphics.drawLine(300,0,300,600);
        int lineNum = frameSize / step;
        for (int i = 0; i < lineNum ; i++) {
            graphics.drawLine(0,i*step,frameSize,i*step);
            graphics.drawLine(i*step,0,i*step,frameSize);
        }
        snakeHead.paintSelf(graphics);
    }

    public static void main(String[] args) {
        GameFrame gameFrame = new GameFrame();
        gameFrame.launch();

    }
}
